import {type MaybeRef, unref} from "vue";
import axiosInstance from "../utils/axios.ts";
import type {Car, CarVO} from "../types";

export const getCars = (companyId: MaybeRef<number | undefined>) => {
  return axiosInstance.post<any,Car[]>("/car/getList", undefined, {
    params: {
      id: unref(companyId)
    }
  })
}

export const insertCar = (car: CarVO) => {
  return axiosInstance.post("/car/save", car)
}

export const updateCar = (car: CarVO) => {
  return axiosInstance.put("/car/update", car)
}

export const deleteCar = (carId: number) => {
  return axiosInstance.delete<any, boolean>("/car/delete", {
    params: {
      id: carId
    }
  })
}